import React from 'react';
import { WeaTag } from 'ecCom';
export default class NewTag extends React.Component{
  constructor(props){
    super(props)
  }
  render(){
    const {linkdatas} = this.props;
    return(
       <div className="wea-workrelate-newtag">
          {
            linkdatas && linkdatas.length > 0 && linkdatas.map((element,idx)=>{
              return (
                element.name?<span title={element.name}><WeaTag ecId={`${this && this.props && this.props.ecId || ''}_WeaTag@iqhc6s@${element.id}`} key={element.id} id={element.id} color={element.color} style={{marginRight: 10}} closable={true} onClose={(e) => this.onLinkClose(element.id,e)}> {element.name}</WeaTag></span>:""
              )
            })
          }
       </div>
    )
  }
  onLinkClose(id,e){
    if(typeof this.props.onLinkClose === "function"){
      this.props.onLinkClose(id);
    }else{
      console.log(id);
    }
    e.stopPropagation();
    e.nativeEvent.stopImmediatePropagation();
  }
}